package com.oracle.controller;

import com.oracle.common.PageResult;
import com.oracle.common.R;
import com.oracle.pojo.Xsws;
import com.oracle.service.XswsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("xsws")
public class XswsController {
    @Autowired
    private XswsService xswsService;

    @GetMapping("find")
    public List<Xsws> findList()
    {
        List<Xsws> list = xswsService.findList();
        return list;
    }

    @PostMapping("find2")
    public R<Xsws> findPages2(@RequestBody Xsws xsws, Integer pageNo, Integer pageSize)
    {
        if(ObjectUtils.isEmpty(pageNo)){
            pageNo = 1;
        }

        if(ObjectUtils.isEmpty(pageSize)){
            pageSize = 10;
        }

        PageResult pages = xswsService.findPages(pageNo, pageSize,xsws);
        return R.success(pages);
    }
}
